#include "StdAfx.h"
#include "Random.h"
#include <stdlib.h>
#include <time.h>

Random::Random(unsigned int low_bound, unsigned int up_bound)
: m_low_bound(low_bound), m_up_bound(up_bound)
{
	static bool initialized = false;
/* todo: nie jest threadsafe */
	if(!initialized)
	{
		srand((unsigned)time(NULL));
		initialized = true;
	}
}

Random::~Random(void)
{
}

unsigned int Random::GetNumber()
{
 return GetNumber(m_low_bound, m_up_bound);
}

unsigned int Random::GetNumber(unsigned int up_bound)
{
	return GetNumber(0, up_bound);
}

unsigned int Random::GetNumber(unsigned int low_bound, unsigned int up_bound)
{
	return (unsigned) (rand() + m_low_bound) % (m_up_bound + 1);
}